package com.zhihaihe.file.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhihaihe.file.dto.announcement.QueryDTO;
import com.zhihaihe.file.pojo.AnnouncementEntity;
import com.zhihaihe.file.mapper.AnnouncementDao;
import com.zhihaihe.file.service.AnnouncementService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 公告板
 * @author
 */
@Service("announcementService")
public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementDao, AnnouncementEntity> implements AnnouncementService {

    @Autowired
    AnnouncementDao announcementDao;

    @Override
    public Page likePage(Page params, QueryDTO entity) {
        QueryWrapper<AnnouncementEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(entity.getType()),entity.getType(),"%"+entity.getContent()+"%");
        queryWrapper.orderByDesc("publishtime");
        return page(params,queryWrapper);
    }
}